home *** CD-ROM | disk | FTP | other *** search
/ Megaware 1 / Megaware Volume 1.iso / programg / c-tutor / class1.cpp < prev    next >
Text File  |  1990-07-20  |  673b  |  38 lines

  1.                                  // Chapter 2 - Program 3
  2. #include "iostream.h"
  3.  
  4. class animal {
  5. public:
  6.    int weight;
  7.    int feet;
  8. };
  9.  
  10. main()
  11. {
  12. animal dog1, dog2, chicken;
  13. animal cat1;
  14. class animal cat2;
  15.  
  16.    dog1.weight = 15;
  17.    dog2.weight = 37;
  18.    chicken.weight = 3;
  19.  
  20.    dog1.feet = 4;
  21.    dog2.feet = 4;
  22.    chicken.feet = 2;
  23.  
  24.    cout << "The weight of dog1 is " << dog1.weight << "\n";
  25.    cout << "The weight of dog2 is " << dog2.weight << "\n";
  26.    cout << "The weight of chicken is " << chicken.weight << "\n";
  27. }
  28.  
  29.  
  30.  
  31.  
  32. // Result of execution
  33. //
  34. // The weight of dog1 is 15
  35. // The weight of dog2 is 37
  36. // The weight of chicken is 3
  37.  
  38.